from random import randint
import pdb

n = randint(1, 16)
n = 35

survivor = []

for i in range(1, n):
    survivor.append(i)

print(survivor)

idx = 0
countOff = 1
#pdb.set_trace()
while len(survivor) > 1:
    if(countOff % 3 == 0):
        del survivor[idx]
        print(survivor)
        idx = len(survivor)-1 if idx == 0 else idx - 1

    countOff = (countOff + 1) % 3
    idx = (idx + 1) % len(survivor)
